#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const int MAXD=(int)2e9;
const int MAXN=(int)1e5*8;
int low[MAXN],high[MAXN],cover[MAXN], NP;
void INIT()
{
      memset(low,-1,sizeof(low));
      memset(high,-1,sizeof(high));
      memset(cover,0,sizeof(cover));
      NP=1;
}
void INSERT(int L, int R, int CL, int CR, int node)
{
      if(L<CL)L=CL;
      if(R>CR)R=CR;
      if(L>R)return ;
      if(L==CL&&R==CR)
      {
          cover[node]++;
         // printf("INSERT:NODE%d[%d,%d],now%d\n",node,CL,CR,cover[node]);
          return ;
     }
     if(low[node]==-1||high[node]==-1)
     {
          low[node]=NP++;
          high[node]=NP++;
     }
     int MD=(CL+CR)/2;
     INSERT(L,R,CL,MD,low[node]);
     INSERT(L,R,MD+1,CR,high[node]);
      return ;
}
int QUERY(int T,int CL,int CR,int node)
{
     if(node==-1)return 0;
     if(T<CL||T>CR)return 0;
     int MD=(CL+CR)/2;
     return cover[node]+QUERY(T,CL,MD,low[node])+QUERY(T,MD+1,CR,high[node]);
}
int main()
{
     int ncase;
     scanf("%d", &ncase);
     for(int icase=0;icase<ncase;icase++)
    {
        int N,M;
        scanf("%d%d",&N,&M);
        INIT();
        for(int i=0;i<N;i++)
        {
            int L,R;
            scanf("%d%d",&L,&R);
            INSERT(L,R,1,(int)1e9+10,0);
        }
        printf("Case #%d:\n",icase+1);
        for(int i=0;i<M;i++)
        {
            int T;
            scanf("%d",&T);
            printf("%d\n",QUERY(T,1,(int)1e9+10,0));
        }
    }
    //system("")
    return 0;
}
